package com.krain.ddbb.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.krain.corelibrary.widget.recyleview.BaseRecyclerViewAdapter;
import com.krain.ddbb.R;
import com.krain.ddbb.entity.AccountDetailBean;
import com.krain.ddbb.entity.ServiceRmarkBean;

import java.util.List;

/**
 * Created by ex-kuangxiaomin101 on 2016-02-19.
 */
public class AccountDetailAdapter extends BaseRecyclerViewAdapter<AccountDetailAdapter.ViewHolder> {

    private List<AccountDetailBean> mList;
    private Context context;

    public AccountDetailAdapter(List<AccountDetailBean> mList, Context context) {
        this.mList = mList;
        this.context = context;
    }

    public List<AccountDetailBean> getList() {
        return mList;
    }

    public void reflush(List<AccountDetailBean> mList) {
        this.mList = mList;
    }


    @Override
    public ViewHolder getViewHolder(View itemView) {
        return new ViewHolder(itemView);
    }

    @Override
    public View getItemView(int viewType, ViewGroup parent) {
        return LayoutInflater.from(context).inflate(R.layout.item_account_detail_list, parent, false);
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.item_account_money.setText(mList.get(position).getMoney());
        holder.item_remark_time.setText(mList.get(position).getTime());
        if (mList.get(position).getType().equals(AccountDetailBean.TYPE_INCOME)) {
            holder.item_account_detail.setText("账户收入");
        } else {
            holder.item_account_detail.setText("账户提现");
        }
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        public TextView item_account_money;
        public TextView item_account_detail;
        public TextView item_remark_time;


        public ViewHolder(View itemView) {
            super(itemView);
            item_account_money = (TextView) itemView.findViewById(R.id.item_account_money);
            item_account_detail = (TextView) itemView.findViewById(R.id.item_account_detail);
            item_remark_time = (TextView) itemView.findViewById(R.id.item_account_time);
        }
    }
}
